package com.example.demo.controller;

import com.example.demo.listener.MyEven;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class MyController {
    @Resource
    ApplicationContext applicationContext;

    @RequestMapping("/user")
    public String test(){
        return "fan";
    }

    @RequestMapping("/hello")
    public String hello(){
        applicationContext.publishEvent(new MyEven(this,"fan"));
        return "hello";
    }
}
